import query from '@dfeidao/atom-nodejs/db/query';
import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '../../atom/config';

interface Message {
	safety_department_no: string;
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:f:\实习\kh\src\wyf-hManager\zj-000004\s002,action_id:' + action_id);

	// 依据负责部门下拉框数据选择负责人下拉框的数据
	const { prepare: p, exec } = query(action_id, session_id, systemid);
	p('total_staff_inf', ['staff_name', 'staff_no'], { safety_department_no: message.safety_department_no }, 200, 1, [], []);
	const [res] = await exec();

	log('Service end path:f:\实习\kh\src\wyf-hManager\zj-000004\s002,action_id:' + action_id);
	return {
		data: res
	};
}
